** Create Tables 2, 3: Correlations and cell percentages of grouping variables

use  data_long.dta, clear


*************************************************************

*** Table 2: Correlation of group variables

*************************************************************
	
	pwcorr know_sum pred_bundes_gov_r authoritarian conspiracy_sum pred_Russia
	
	corrtex authoritarian conspiracy_sum know_sum pred_bundes_gov_r pred_Russia,  file(table2) title("Correlation of grouping variables") replace digits(2)


*************************************************************

*** Table 3: Group sizes (cell percentages)

*************************************************************

	gen know_d = .
	replace know_d = 1 if know_sum > .5 & know_sum != .
	replace know_d = 0 if know_sum <= .5 & know_sum != .
	label var know_d "Knowledge dummy"

	gen pre_gov_d = .
	replace pre_gov_d = 1 if pred_bundes_gov_r > .5 & pred_bundes_gov_r != .
	replace pre_gov_d = 0 if pred_bundes_gov_r <= .5 & pred_bundes_gov_r != .
	label var pre_gov_d "Attitudes twd German government dummy"
	tab pred_bundes_gov_r pre_gov_d, mis

	gen conspiracy_d = .
	replace conspiracy_d = 1 if conspiracy_sum > .5 & conspiracy_sum != .
	replace conspiracy_d = 0 if conspiracy_sum <= .5 & conspiracy_sum != .
	label var conspiracy_d "Conspiracy beliefs dummy"
	tab conspiracy_sum conspiracy_d, mis

	gen authoritarian_d = .
	replace authoritarian_d = 1 if authoritarian > .5 & authoritarian != .
	replace authoritarian_d = 0 if authoritarian <= .5 & authoritarian != .
	label var authoritarian_d "Authoritarianism dummy"
	tab authoritarian authoritarian_d, mis

	gen pred_Russia_d = .
	replace pred_Russia_d = 1 if pred_Russia_r > .5 & pred_Russia_r != .
	replace pred_Russia_d = 0 if pred_Russia_r <= .5 & pred_Russia_r != .
	label var pred_Russia_d "Authoritarianism dummy"
	tab pred_Russia_r pred_Russia_d, mis


	**Cell entries for Table 3 (Latex table created by hand)
	tab know_d conspiracy_d, cell nof
	tab know_d  authoritarian_d, cell nof
	tab authoritarian_d conspiracy_d, cell nof

	tab know_d conspiracy_d [aw = weight1], cell nof
	tab know_d  authoritarian_d [aw = weight1], cell nof
	tab authoritarian_d conspiracy_d [aw = weight1], cell nof


***Text: Perceptage of people with three vulnerable characteristics and three immunizing characteristics

	gen vulnerable_d = 0
	replace vulnerable_d = 1 if know_d == 0 & conspiracy_d == 1 & authoritarian_d == 1
	label var vulnerable_d "People with three vulnerable characteristics"
	gen immune_d = 0
	replace immune_d = 1 if know_d == 1 & conspiracy_d == 0 & authoritarian_d == 0
	label var immune_d "people with three immunizing characteristics"

	tab vulnerable_d [aw = weight1]
	tab immune_d [aw = weight1]
